package xyz.xtt.asset.enums;

import java.util.Arrays;
import java.util.Objects;

import xyz.xtt.asset.api.enums.AssetTypeEnum;

/**
 * 经营证类型
 * 
 * 
 * @author huqibo
 * 
 *         资产状态
 */
public enum CertificateTypeEnum {

	/**
	 * A类经营证
	 */
	A(AssetTypeEnum.BIZ_CERTIFICATE, 0, "A类"),
	/**
	 * B类经营证
	 */
	B(AssetTypeEnum.BIZ_CERTIFICATE, 1, "B类");

	/**
	 * 一级分为类
	 */
	private AssetTypeEnum assetTypeEnum;
	/**
	 * 编码
	 */
	private int code;
	/**
	 * 描述
	 */
	private String desc;

	private CertificateTypeEnum(AssetTypeEnum assetTypeEnum, int code, String desc) {
		this.assetTypeEnum = assetTypeEnum;
		this.code = code;
		this.desc = desc;
	}

	public AssetTypeEnum assetType() {
		return assetTypeEnum;
	}

	public int code() {
		return code;
	}

	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(CertificateTypeEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static CertificateTypeEnum queryConvert(Integer checkType) {
		return Arrays.asList(CertificateTypeEnum.values()).stream().filter(x -> Objects.equals(x.code(), checkType)).findFirst().orElse(null);
	}

	public static CertificateTypeEnum convert(String checkType) {
		return Arrays.asList(CertificateTypeEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType)).findFirst().orElseGet(null);
	}
}
